<include file="__THEME__/header" />
<link href="../Public/css/bbs.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/js/kissy/themes/default/editor-min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/js/kissy/neweditor.js"></script>
<div class="ask_add"> {:L('current_position')}：{$_topnav} > {:L('new_thread')} </div>
<style>
	.expert_id a{ margin-left:5px;}
</style>
<!--发布样式 begi-->
<div class="contents">
  <div class="lineC">
    <h3 class="tit_bg">{:L('new_thread')}</h3>
    <div class="add_vote" style="width:99%; overflow:hidden;">
	<form action="{:U('bbs/Do/post')}" method="post" onsubmit="return checkForm();return false;" autocomplete="off">
	<input type="hidden" name="board" id="bbs_category" value="{$class}">
      <table align="left" style="line-height:25px;" width="100%">
        <tr height="10">
          <td width="10%">&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
         <tr height="10">
          <td align="right" valign="top" >{:L('board')}：</td>
          <td align="left">
          	<div id="categorySelectedList" style="float:left;color:#666;">
			{$defaultCategory|implode=' > ',###}
			&nbsp;</div> 
            <div  style="float:left; _padding-top:5px;" >
            	<img class="pl5 alM" src="../Public/images/title_icon_02.gif" align="absmiddle" />
				<a class="pl5" href="javascript:void(0)" onclick="selectCategory()" >{:L('board_change')}</a>
			</div>
		</td>
        </tr>		
        <tr height="40">
          <td align="right" valign="top">{:L('edit_title')}：</td>
          <td align="left">
          	<select name="tclass" id="tclass" class="in_put_01">
          		<php>if( $tclasslist  ){</php>
	       			<volist id="vo" name="tclasslist">
	       				<php>$selected=($_GET['tclass']==$key)?'selected':''</php>
	          			<option value="{$key}" {$selected}>{$vo}</option>
					</volist>
				<php>}else{</php>
          			<option value="0">{:L('edit_default_tclass')}</option>
				<php>}</php>
   
          	</select>
			<input type="text"  name="title" maxlength="50" id="title" class="in_put" style="width:350px;" value=""/>
            <div class="L" id="vote">{:W('Vote',array('app'=>'bbs', 'field'=>'id', 'fieldId'=>'0', 'type'=>'edit', 'tpl'=>'Vote'))}</div>
			</td>
        </tr>
        <tr height="30">
          <td align="right" valign="top">{:L('edit_content')}：</td>
          <td align="left">
        	<textarea  class="in_put" name="content"  cols="" rows="20" id="content" style="width:680px" ></textarea>
          </td>
        </tr>
        <tr height="40">
          <td align="right" >{:L('thread_tag')}：</td>
          <td align="left"><input class="w125 in_put mr10" name="tags" id="tags" type="text" />
            <a class="pr10" href="javascript:void(0)" onclick="autoTags()">{:L('thread_tag_auto')}</a><span class="cl06">{:L('thread_tag_info')}</span></td>
        </tr>
        <tr height="30">
          <td align="right" valign="top" class="pt15">{:L('thread_attach')}：</td>
          <td align="left" valign="top" class="pt10">
              <div>{:W( 'UploadAttach',array( 'uid'=>$mid , 'type'=>'bbs' , 'callback'=>'attach_upload_success') )}</div>
			  <div class="attach"></div>
           </td>
	   </tr>	   

        <tr height="30">
          <td align="right" valign="center">{:L('thread_transcribe')}：</td>
          <td align="left" ><a href="javascript:void(0)" id="transcribehandle" onclick="transcribe()">{:L('thread_add_transcribe')}</a>
		  <input type="hidden" name="transcribeuid"   id="transcribeuid">   <!-- 已注册的uid -->
		  <input type="hidden" name="transcribeuname" id="transcribeuname"> <!-- 未注册的uname -->
		       <div id="expertUserList">
				</div>
		  </td>
        </tr> 
         <tr height="50">
          <td></td>
          <td align="left" valign="middle">
            <input class="btn_sea " name="" type="submit" value="{:L('edit_submit')}" /></td>
        </tr>
      </table>
	  	</form>
      </div>
    <!--右边警告 begin-->
    <div class="C"> </div>
  </div>
  <!--右边警告 begin-->
</div>
<script>

	
$(document).ready(function(){
	checkBoard();	
	E	=	KISSY.Editor( "content" );
});

//抄送
function transcribe(){
	$.tbox.popup("{:U('bbs/Index/transcribe')}&uids="+$("#transcribeuid").val(),'{:L("thread_add_transcribe")}',{ok:'savetranscribe'});
}



//自动获取Tag
function autoTags(){
	var content =  E.getData()+" "+$('#title').val();
	$.post("{:U('ask/do/getTags')}",{content:content},function(result){
		$('#tags').val(result);
	})
}

//选择分类
function selectCategory(){
	var o = ($("#bbs_category").val())?"&class="+$("#bbs_category").val():'';
	$.tbox.popup("{:U('bbs/Index/selectCategory')}"+o,"{:L('select_full_category')}",false);
}

//确定选择
function ok(){
	var categoryId    = new Array();
	var categoryTitle = new Array();
	
	for(i=0;i<=2;i++){
		if( $("#sel"+i).val()!=0 && $("#sel"+i).val()!=undefined ){
			categoryId[i]     = $("#sel"+i).val();
			categoryTitle[i]  = $("#sel"+i+" option[value="+categoryId[i]+"]").html();
		}		
	}
	if( categoryId.length < 2 ){
		$("#boardMessage").html('{:L("select_full_category")}',"{:L('wrong')}");
		return false;
	}else{
		 var selecttagid = categoryId[categoryId.length-1];
		 $.getJSON("{:U('bbs/Index/getCategory')}",{tagid:selecttagid},function(txt){
		 		var optionlist = '';
				if(txt){
			 		$.each(txt,function(i,n){
						optionlist += '<option value='+i+'>'+n+'</option>';
					});
				}else{
					optionlist += '<option value=0>{:L("edit_default_tclass")}</option>';
				}

				$('#tclass').html(optionlist);
		 });
		 var browse_category_title = categoryTitle.join(' > ');
		 var browse_category_id = categoryId.join(',');
		 $('#categorySelectedList').html(browse_category_title);
		 $('#bbs_category').val(browse_category_id);
		 $.tbox.close();
		 //location.href="{:U('bbs/Index/post')}&class="+browse_category_id;
	 }
}

function checkBoard(){
	var selectedclass = $('#bbs_category').val();
	selectedclass = selectedclass.split(',');
	if( selectedclass.length < 2 ){
		selectCategory();
		return false;
	}else{
		return true;
	}
	
}

function checkForm(){
	if( checkBoard() ){
		if( $.trim( $('#title').val() ) <=5 ){
			$.tbox.no("{:L('edit_un_validate')}","{:L('wrong')}");
			$('#title').focus();
			return false;
		}
		
		if( E.getData().length<2 ){
			$.tbox.no("{:L('edit_content_empty')}","{:L('wrong')}");
			E._focusToEnd()
			return false;
		}
		
	}else{
		return false;
	}
}

</script>
<include file="__THEME__/footer" /> 